package com.deyou.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.deyou.R;
import com.deyou.model.CityPoiBean;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yangyuancheng on 2017/8/16.
 */

public class CityPoiAdapter extends BaseQuickAdapter<CityPoiBean, CityPoiAdapter.ViewHolder> {

    private Context mContext;
    private String selectedId;

    public void setSelectedId(String selectedId) {
        this.selectedId = selectedId;
        notifyDataSetChanged();
    }

    public CityPoiAdapter(Context context) {
        super(R.layout.city_poi_item);
        this.mContext = context;
    }

    @Override
    protected void convert(ViewHolder helper, CityPoiBean item) {
        helper.tvPoiValue.setText(item.name);
        if (!TextUtils.isEmpty(selectedId)) {
            if (selectedId.equals(item.poiInfoId)) {
                helper.tvPoiValue.setTextColor(mContext.getResources().getColor(R.color.color_FF832D));
            } else {
                helper.tvPoiValue.setTextColor(mContext.getResources().getColor(R.color.color_272424));
            }
        } else {
            helper.tvPoiValue.setTextColor(mContext.getResources().getColor(R.color.color_272424));
        }
    }

    static class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_poi_value)
        TextView tvPoiValue;

        ViewHolder(View view) {
            super(view);
            AutoUtils.autoSize(view);
            ButterKnife.bind(this, view);
        }
    }
}
